<?php

	direct_url();
	$id = $_GET['id'];
	$data=cache_get_truyen($id);
	//Truyen ten truyen vao, tao ra tag
	if(!$data){
	redirect(HOME);
	}
	
	//Kiem tra fiel gtag , neu =1 thi thoi, chua = 1 thi update tag ngay
	
	$baseurl=url_truyen($data['id'],$data['alias']);
	

	if(!isset($_GET['page'])){
	$data['chuong_list']=cache_get_truyen_chuong_list($id,1);
	}else{
		
		$page=intval($_GET['page']);
		
		$data['chuong_list']=cache_get_truyen_chuong_list($id,$page);
	}
 //get the loai truyen cung tac gia ----------
 //query facebook, udpate sau
 /*
	$fb=new shareCount(url_truyen($data['id'],$data['alias']));
	$count=$fb->get_fb();
	$db=new db;
	$db->connect();
	$db->nonquery("update truyen set likes=".$count['like']." , comments=".$count['comment']." where id=$id");
	$db->close();
	*/
// End get truyen cung tac gia-------
	$og='
<meta property="og:type" content="book" />
<meta property="og:image" content="'.TRUYEN_IMAGE_LOCAL.$data['hinhanh'].'"/>
<meta property="og:locale" content="vi_VN" /> 
<meta property="og:title" content="'.$data['ten'].' -Tác giả '.$data['tacgia'].'| Đọc Truyện Online Mong.vn"/>
<meta property="og:description" content=" '.encode($data['gioithieu']).'| Mong.vn"/> 
<meta property="og:url" content="'.url().'"/> ';
   $data1['og']=$og;
   	//Lay the loai 2, lay duoc list chuong, update view, update so chuong hien co,update view
	
	//HEADER TITLE,KEYWORD,DESCRIPION
	$data1['title']=web_title(encode($data['ten'])."- Tác giả ".$data['tacgia']);
	$data1['mota']=web_des(encode($data['gioithieu']));
	$data1['keyword']=web_keyword($data['ten'].",".$data['alias'].", doc truyen ".$data['ten']);

loadview('template/header',$data1);
loadview("truyen/view",$data);


 //    loadview("template/right",$right);

?>